<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="module">
        import {consoleprint} from "./modules/first.js"
        consoleprint("set")
        let arr1 = new Array()
        arr1.push(1);
        arr1.push(2);
        arr1.push(...[3,4]);
        console.log("arr1:",arr1) //[1, 2, 3, 4]

        let s1 = new Set(arr1)
        console.log("set:",s1) // {1, 2, 3, 4}
        s1.add(1)
        s1.add(6);
        s1.delete(1)
        s1.add(7).delete(7)
        console.log("set:",s1) // {2, 3, 4, 6}
        //判断是否有元素
        console.log(s1.has(1)); // false
        console.log("容量:",s1.size) // 容量4

        // key,value一样
        for(let i of s1.values() ){ // 默认循环 values
            console.log(i)
        }

        for(let [k,v] of s1.entries()){ // 默认循环 values
            console.log(k,v)
        }
        s1.forEach(function (value,index) {
            console.log("foreach:",value,index)
        })

        //清空
        s1.clear();
        console.log(s1.size); // 容量4

        consoleprint("转换数组");
        let arr2 = new Array([1,2,3,4,5,6,7,7,8,5,45]);
        let arr3 = new Array(...new Set(arr2));
        console.log(arr3);
        console.log(Array.from(new Set(arr2)))

        let json1 = {"a":1}
        let json2 = {"a":1}


    </script>
</head>
<body>
<div>不能有重复的set</div>
</body>
</html>